package org.catspaw.cherubim.persistence.hibernate;

public final class HibernateCacheUtils {

	private HibernateCacheUtils() {
	}

	/**
	 * @see org.hibernate.Session#clear()
	 */
	public static void clear() {
		SessionManager.getInstance().getSession().clear();
	}

	/**
	 * @see org.hibernate.Session#evict(Object)
	 * @param entity 实体对象
	 */
	public static void evict(Object entity) {
		SessionManager.getInstance().getSession().evict(entity);
	}

	/**
	 * @see org.hibernate.SessionFactory#evict(Class)
	 */
	public static void evictFromSessionFactory(Class<?> clazz) {
		SessionManager.getInstance().getSessionFactory().getCache().evictEntityRegion(clazz);
	}

	/**
	 * 刷新缓存
	 */
	public static void flush() {
		SessionManager.getInstance().getSession().flush();
	}
}
